{extend name="base" /}
{block name="body"}
<style type="text/css">
.mleft {
    margin-right: 10px;
}
</style>
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">充值记录</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
             <div class="layui-form-item">
                <form class="layui-form layui-form-pane" action="{:url('admin/player/plog')}" method="get">
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">数据查询</label>
                        <div class="layui-input-inline">
                            <input type="text" name="keyword" value="{:input('keyword')}" placeholder="请输入账号或订单号" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline mleft">
                      <label class="layui-form-label">游戏区服</label>
                      <div class="layui-input-inline" style="width: 130px;">
                        <select name="game" lay-filter="game" id="game">
                            <option value="">请选择游戏</option>
						    {foreach name="game_list" item="vo"}
							<option value="{$vo.id}"{if condition="$data.game == $vo.id"} selected{/if}>{$vo.name}</option>
							{/foreach}
                        </select>
                      </div>
                      <div class="layui-input-inline" style="width: 130px;">
                        <select name="area" id="area" lay-verify="required" lay-filter="area" lay-search="" {if condition="$data.game == null"} disabled{/if}>
                          <option value="">请选择区服</option>
                        </select>
						<input type="hidden" id="areaname" value="{:input('area')}">
                      </div>
                    </div>
                     <div class="layui-inline mleft">
                      <label class="layui-form-label" style="width: 60px;">状态</label>
                      <div class="layui-input-inline" style="width: 100px;">
                        <select name="status" lay-filter="status">
                            <option value="0">所有</option>
							<option value="1" {if condition="$data.status == 1"} selected{/if}>未支付</option>
                            <option value="2" {if condition="$data.status == 2"} selected{/if}>已支付</option>
                            <option value="3" {if condition="$data.status == 3"} selected{/if}>已充值</option>
                        </select>
                      </div>
                    </div>  
                    <div class="layui-inline mleft">
                        <label class="layui-form-label">范围选择</label>
                        <div class="layui-input-inline" style="width: 200px;">
                            <input name="starttime" value="{:input('starttime')}" class="layui-input" placeholder="开始日" id="starttime">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline" style="width: 200px;">
                          <input name="endtime" value="{:input('endtime')}" class="layui-input" placeholder="截止日" id="endtime">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn">搜索</button>
                    </div>
                </form>
              </div>
                <hr>

                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>系统订单号</th>
                        <th>玩家账号</th>
						<th>代理名称</th>
                        <th>游戏名称</th>
                        <th>区服名称</th>
                        <th>充值金额</th>
						<th>充值时间</th>
						<th style="width: 55px">状态</th>
						<th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
						{foreach name="pay_list" item="vo"}
						<tr id="tr_{$vo.porder}" style="cursor:pointer;" onclick="showRow('{$vo.porder}')" >
							<td>{$vo.porder}</td>
							<td>{$vo.uid}</td>
							<td>{$vo.aname}</td>
							<td>{$vo.name}</td>
							<td>{$vo.sname}</td>
							<td>{$vo.amount}</td>
							<td>{$vo.pay_time}</td>
							<td>{switch name="$vo['pay_status']" }
                            {case value="0"}<font color=red>未支付</font>{/case}
                            {case value="1"}已支付{/case}
							{case value="2"}已充值{/case}
							{default /}异常
                            {/switch}
							</td>
						    <td>
							    {if condition="$vo['pay_status'] == '1'"}
								<a data-url="{:url('admin/player/handleorder')}" data-type="fill" data="{$vo['id']}" class="layui-btn layui-btn-warm layui-btn-mini ajax-post">补单</a>
								{else /}
								<a class="layui-btn layui-btn-disabled layui-btn-mini">补单</a>
								{/if}
						    </td>
						</tr>
                        <tr id="append_{$vo.porder}" style="display:none;">
						    <td colspan="12">
							<font color="blue">下游订单号：</font>
							<font color="red" style="margin-right:10px;">{$vo.aorder}</font>
							<font color="blue">系统订单号：</font>
							<font color="red" style="margin-right:10px;">{$vo.porder}</font>
							<font color="blue">支付类型：</font>
							<font color="red" style="margin-right:10px;">{$vo.type}</font>
							<font color="blue">代理ID：</font>
							<font color="red" style="margin-right:10px;">{$vo.aid}/{$vo.nickname}</font>
                            <font color="blue">提交时间：</font>
							<font color="red" style="margin-right:10px;">{$vo.pay_time}</font>
							</td>
						</tr>
						{/foreach}
                    </tbody>
                </table>
                <!--分页-->
				{:$pay_list->render()}
            </div>    
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
layui.use(['jquery','laydate'],function () {
    var laydate = layui.laydate;
    var $ = layui.$;

var startDate = layui.laydate.render({
  elem: '#starttime',
  min: '2017-12-28',
    type: 'datetime',
    //btns: ['confirm'],
  done:function(value,date){
    if( value !== '' ){
      endDate.config.min.year = date.year;
      endDate.config.min.month = date.month - 1;
      var day = date.date;
      if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
        day = day + 1;
      }else{
        endDate.config.min.hours = date.hours;
        endDate.config.min.minutes = date.minutes;
        endDate.config.min.seconds = date.seconds;
      }
      endDate.config.min.date = day;
      endDate.config.btns = ['clear','confirm'];
    }else{
      endDate.config.min.year = '';
      endDate.config.min.month = '';
      endDate.config.min.date = '';
      endDate.config.min.hours = '';
      endDate.config.min.minutes = '';
      endDate.config.min.seconds = '';
      endDate.config.btns = ['clear','now','confirm'];
    }
  }
});


var endDate = layui.laydate.render({
  elem: '#endtime',
  min: '2017-12-28',
    type: 'datetime',
    //btns: ['confirm'],
  done:function(value,date){
    if( value !== '' ){
      startDate.config.max.year = date.year;
      startDate.config.max.month = date.month - 1;
      var day = date.date;
      if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
        day = day - 1;
      }else{
        startDate.config.max.hours = date.hours;
        startDate.config.max.minutes = date.minutes;
        startDate.config.max.seconds = date.seconds;
      }
      startDate.config.max.date = day;          
      startDate.config.btns = ['clear','confirm'];
    }else{
      startDate.config.max.year = '';
      startDate.config.max.month = '';
      startDate.config.max.date = '';

      startDate.config.max.hours = '';
      startDate.config.max.minutes = '';
      startDate.config.max.seconds = '';
      startDate.config.btns = ['clear','now','confirm'];
    }
  }
});
});
	
layui.use(['form', 'laydate'], function(){
    var form = layui.form;
     var laydate = layui.laydate;
     
	//监听开启开关
      form.on('switch(checkbtn)', function(data){
        var url  = $(this).attr('data-url');
    	var date = $(this).attr('data');
    	var type = this.checked ? 1:0;
    	$.post(url,{id:date,type:type},function(info){
    	    layer.msg(info.msg);	
    		})
    });
    //监听开启开关
    form.on('select(game)', function(data){
	    if (data.value){
		    var gid  =  data.value;
            $("#area").removeAttr("disabled");
		    $('#area').empty();	
			$.get("/admin/player/getgarea",{gid:gid}, function(info){
			$("#area").append('<option value="">请选择区服</option>');
			    if (info.length > 0){
                    for (var i=0;i<info.length;i++){
				        var sid   = info[i].id;
				    	var sname = info[i].sname;
				    	$("#area").append('<option value="' + sid  + '">' + sname + '</option>');
                    }
				}else{
				    layer.msg('获取区服列表失败,可能没有区服数据');
				}
				form.render('select');
			});
		}
    });

   $(document).ready(function(){
    var game = $('#game option:selected').val();
	var areaname = $("#areaname").val();
       if (game !== ""){
	    $.get("/admin/player/getgarea",{gid:game}, function(info){
               if (info.length > 0){
                   for (var i=0;i<info.length;i++){
			        var sid   = info[i].id;
			    	var sname = info[i].sname;
			    	if (sid == areaname){
			    	    $("#area").append('<option value="' + sid  + '"  selected="">' + sname + '</option>');
			    	}else{
			    	    $("#area").append('<option value="' + sid  + '">' + sname + '</option>');
			    	}
                   }
			}else{
			    layer.msg('获取区服列表失败,您可能没有申请区服');
			}
			form.render('select');
		});
	   
	} 
		
   });
});
</script>
{/block}